﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using XiaoMan.Model.Models;
using XiaoMan.API.Filter;
using XiaoMan.API.Models;

namespace XiaoMan.API.Controllers
{
    [ApiHandleError]
    //[AuthFilter]
    public class ApiBaseController : ApiController
    {
        /// <summary>
        ///  返回业务成功的对象结构
        /// </summary>
        /// <param name="model">返回的对象</param>
        /// <param name="message">提示的消息 选填</param>
        /// <returns></returns>
        public IHttpActionResult ApiSuccess(object model,string message="success")
        {            
            return Json(new ApiBaseModel { message = message, status = true, result = model });
        }

        /// <summary>
        /// 返回业务失败的错误信息
        /// </summary>
        /// <param name="messageCode"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public IHttpActionResult ApiFail(string message)
        {
            return Json(new ApiBaseModel { message = message, status = false, result = null });
        }
    }
}
